package com.fulihui.wgj.facade.service.platform;

import com.fulihui.common.error.InvokeServiceException;
import com.fulihui.common.result.rpc.BaseResult;
import com.fulihui.common.result.rpc.SimpleResult;
import com.fulihui.wgj.facade.dto.WxPlatformDTO;
import com.fulihui.wgj.facade.request.platform.WxPlatformLoginPageRequest;
import com.fulihui.wgj.facade.request.platform.WxPlatformPageRequest;
import com.fulihui.wgj.facade.request.platform.WxPlatformQueryRequest;
import com.fulihui.wgj.facade.result.platform.WxPlatformPageResult;
import com.fulihui.wgj.facade.result.platform.WxPlatformQueryResult;

import java.util.List;

/**
 * 微信公众号WxPlatformServiceService
 *
 * @author wang_wx
 * @date 2018-06-20
 */
public interface WxPlatformService {

    /**
     * 分页查询公众号信息
     *
     * @param request
     * @return
     * @throws InvokeServiceException
     */
    WxPlatformPageResult queryWxPlatformPage(WxPlatformPageRequest request) throws InvokeServiceException;

    /**
     * 根据登陆账号分页查询公众号信息--包含微信粉丝统计信息
     *
     * @param request
     * @return
     * @throws InvokeServiceException
     */
    WxPlatformPageResult queryWxPlatformPageHasWxUser(WxPlatformLoginPageRequest request) throws InvokeServiceException;

    /**
     * 授权
     *
     * @param authorizationCode 授权码
     * @return
     */
    BaseResult authorized(String authorizationCode);

    /**
     * 取消授权
     *
     * @param appId 公众号的appId
     * @return
     */
    BaseResult unauthorized(String appId);

    /**
     * 更新授权
     *
     * @param authorizationCode 授权码
     * @return
     */
    BaseResult updateAuthorized(String authorizationCode);

    /**
     * 更新Token
     *
     * @param appId
     * @param token
     * @return
     */
    BaseResult updateToken(String appId, String token, String refreshToken);

    /**
     * 查询有效的公众号
     *
     * @return
     */
    SimpleResult<List<WxPlatformDTO>> queryUsefulPlatform();

    /**
     * 查询公众号信息
     *
     * @param request
     * @return
     * @throws InvokeServiceException
     */
    WxPlatformQueryResult queryWxPlatform(WxPlatformQueryRequest request) throws InvokeServiceException;

    /**
     * 从redis中获取公众号token
     *
     * @param appId
     * @return
     */
    SimpleResult<String> queryTokenFromRedis(String appId);
}
